﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ContosoUniversity.Helpers
{
    public static class UIHelper
    {
        public static ActionResult Redirect(string actionName, string id, bool? saveChangesError)
        {
            if (saveChangesError.HasValue && saveChangesError.Value)
            {
                return new RedirectToRouteResult(actionName, 
                    new System.Web.Routing.RouteValueDictionary { 
                { "id", id }, 
                { "saveChangesError", saveChangesError } });
            }
            else
            {
                return new RedirectToRouteResult(actionName,
                    new System.Web.Routing.RouteValueDictionary { 
                { "id", id } });
            }
        }
    }
}